package com.aqie.easy.doublePointer;

/**
 * 27 原地移除数组元素
 */
public class RemoveElement {
    public static int removeElement(int[] nums, int val) {
        int last, cur;
        for (cur = 0,last = 0; cur < nums.length; cur++){
            if (nums[cur] !=val){
                int tmp = nums[cur];
                nums[cur] = nums[last];
                nums[last] = tmp;
                last++;
            }

        }
        return last;
    }

    public static void main(String[] args) {
        int [] arr = {3,3,3,3,3,3,3,3};
        int val = 3;
        System.out.println(removeElement(arr, val));
    }
}
